﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PointTracker.Controls
{
    public partial class ucNav : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            User u = (User)Session["User"];
            if (u != null)
            {
                if (u.role == UserRole.Admin)
                {
                    addRemoveClass.Visible = false;
                    addRemoveStudent.Visible = false;
                    viewEditPointsScribe.Visible = false;
                    viewEditPointsProfessor.Visible = false;
                }
                else if (u.role == UserRole.Professor)
                {
                    addRemoveProfessor.Visible = false;
                    viewEditPointsScribe.Visible = false;
                    viewEditPointsAdmin.Visible = false;
                }
                else if (u.role == UserRole.Scribe)
                {
                    addRemoveProfessor.Visible = false;
                    addRemoveClass.Visible = false;
                    addRemoveStudent.Visible = false;
                    viewEditPointsProfessor.Visible = false;
                    viewEditPointsAdmin.Visible = false;
                }
                else if (u.role == UserRole.Guest)   // Just in case
                {
                    addRemoveProfessor.Visible = false;
                    addRemoveClass.Visible = false;
                    addRemoveStudent.Visible = false;
                    viewEditPointsScribe.Visible = false;
                    viewEditPointsProfessor.Visible = false;
                    viewEditPointsAdmin.Visible = false;
                }
            }
            else
            {
                u = new User();
                Session["User"] = u;
            }
        }
    }
}